/*
 * Copyright user2010
 * All rights reserved
 */

package org.myorg.applitest.gui.swing.components.panel;

import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;

/**
 *
 * @author user
 */
public class LbzHrzPassword extends JPanel{
    public LbzHrzPassword(String strText, int length){

        initializeComponents(strText, length);

    }
    private void initializeComponents(String strText, int length)
    {
        lblChamp = new JLabel();
        txfPassword = new JPasswordField();

        lblChamp.setText(strText + " :");
        int d = lblChamp.getSize().width;
        length = length -d;

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        this.setLayout(layout);

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lblChamp)
                .addGap(length, length, length)
                .addComponent(txfPassword)
            )
        );

        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(lblChamp)

                    .addComponent(txfPassword)
                )
            )
        );
    }
    public String getText(){

        char[] pass = txfPassword.getPassword();
        String str = new String(pass);

        return str;
    }
    private JLabel lblChamp;
    private JPasswordField txfPassword;
    
}
